Method for distributed clipping outside of view volume

ABSTRACT

A distributed clipping scheme is provided, view frustum culling is distributed in several places in a graphics processing pipeline to simplify hardware implementation and improve performance. In general, many 3D objects are outside viewing frustum. In one embodiment, clipping is performed on these objects with a simple algorithm in the PA module, such as near Z clipping, trivial rejection and trivial acceptance. In one embodiment, the SE and RA modules perform the rest of clipping, such as X, Y and far Z clipping. In one embodiment, the SE module performs clipping by way of computing a initial point of rasterization. In one embodiment, the RA module performs clipping by way of conducting the rendering step of the rasterization process. This approach distributes the complexity in the graphics processing pipeline and makes the design simpler and faster, therefore design complexity, cost and performance may all be improved in hardware implementation.

CROSS REFERENCE TO RELATED APPLICATIONS

The present application relates to U.S. patent application Ser. No.11/592,799 (Docket No. GIQUILA-P001), filed on Nov. 3, 2006, entitled“HIERARCHICAL TILE-BASED RASTERIZATION ALGORITHM” which is incorporatedherein by reference.

BACKGROUND

1. Field of the Invention

The invention relates generally to the field of computer systems andmore particularly to 3D computer graphics processor.

2. Description of Related Art

In 3D computer graphics, the view frustum is the region of a threedimensional space in the modeled world that may appear on a computerdisplay screen represented by the 2D screen space (hereinafter alsoreferred to as the screen space). The exact shape of the view frustummay vary, e.g. it may be a rectangular cube, a rectangular pyramid, orother suitable geometric shape. In an example, the frustum may be formedwith six planes: near plane, far plane, +X plane, −X plane, +Y plane,and −Y plane. The planes that cut the view frustum perpendicular to theviewing direction are called the near plane and the far plane, which mayalso be called the near Z plane and the far Z plane.

3D objects in the view frustum may be represented by multiple geometricprimitives, such as polygons, triangles, line segments, points, or otherappropriate geometric elements. Geometric primitives that fall outsideof the view frustum will not be visible and may be discarded, removed,or abandoned, in view frustum clipping, or culling, operation of thegraphics processing pipeline. Here, culling refers to the completeremoval of a geometric primitive which is completely outside of the viewfrustum while clipping refers to the partial removal of a geometricprimitive which has a partial portion outside of the view frustum.Culling may be considered as a special case of clipping where thepartial portion removed defaults to the complete geometric primitive.Clipping/culling 3D objects outside of the view frustum is not necessaryto achieve a correct image output, but it accelerates the renderingprocess by eliminating the unneeded rasterization and post-processing onprimitives that will not appear on the computer display screen anyway.Graphics processing pipeline typically includes a primitive assemblymodule (hereinafter referred to as the PA module) where 3D objects,which may be represented by multiple vertices computed from a vertexshader module, are converted to geometric primitives such as triangles,lines, points, polygons, or other appropriate geometric elements. Forexample, lines may be drawn from a starting-point (or starting-vertex)to an ending-point (or an ending-vertex) in order to pass conformancetests. The reason is that the ending-vertex may or may not be part ofthe line. PA module may also perform a conversion from the view frustumto the 2D screen space. In some examples, only the X and Y coordinatesare transformed into screen space, while the per-pixel Z values may bestored in a Z-buffer. After processed by the PA module, the primitivesare in the screen space. The rest of the pipe acts only on the screenspace. In some examples, a clipping block may be added behind aprimitive assembly block and before the SE module. In this case, theprimitive assembly block would just assemble the primitives, the clipperblock would clip the primitives and generate more primitives based onthis clipping and than pass it on to a transformation pipe whichtransforms the clipped primitives to the screen space before it entersthe SE module. This whole pipe including the primitive assembly block,clipper block, and the transformation pipe is called the PA module.Graphics processing pipelines typically also include a rasterizationmodule (hereinafter referred to as the RA module) where all the pixelsin a clipping window inside the 2D screen space are rendered. The RAmodule operates on the clipping window which may be a portion of theview frustum. Pixels in the screen space outside of the clipping windowalso need to be clipped/culled, i.e., discarded, removed, or abandoned.In addition to the primitive assembly module and the rasterizationmodule, there may also be additional set up functions (e.g., computingan initial point of rasterization for a primitive) performed in a set upmodule (hereinafter referred to as the SE module). In the prior art,clipping/culling of 3D objects outside of the view frustum is typicallydone in a single place inside a graphics processing pipeline. Such animplementation can cause a bottleneck in the pipeline because of thelarge number of computation required for performing clipping/culling.For an example, view frustum clipping/culling may be done in the screenspace. In this example, all the 3D objects are transformed to screenspace and sent to the setup engine to do the clipping according to theclipping window. The advantage of this approach is that the hardware inthe PA module may be very simple. The disadvantage is that all the 3Dobjects need to be transformed to screen space, even the objects outsideof view frustum or clipping window. This may increase complexity andcost of the graphics processing pipeline implementation. In anotherexample, all 6-plane clipping may be done in the view frustum before theconversion to the 2D screen space. The advantage of this approach isthat all polygons outside of the view frustum are clipped; only thepolygons inside the view frustum are transformed to screen space andsent to setup engine. The disadvantage of this approach is that thealgorithm of doing 6 plane clipping is complex and expensive forhardware implementation.

SUMMARY OF THE INVENTION

In general, in one aspect, the present invention involves a method forclipping in a 3D computer graphics processing pipeline, the 3D computergraphics processing pipeline comprises a view frustum, a clippingwindow, a primitive assembly (PA) module, a set up (SE) module, and arasterization (RA) module, the method comprising: obtaining a primitiveusing the PA module; performing a first clipping of the primitive usingthe PA module; determining an initial point of rasterization for theprimitive using the SE module; performing a second clipping of theprimitive using the SE module; rendering the primitive using the RAmodule; and performing a third clipping of the primitive using the RAmodule.

Other aspects and advantages of the invention will be apparent from thefollowing description and the appended claims.

BRIEF DESCRIPTION OF DRAWINGS

So that the manner in which the above recited features, advantages andobjects of the present invention are attained and can be understood indetail, a more particular description of the invention, brieflysummarized above, may be had by reference to the embodiments thereofwhich are illustrated in the appended drawings.

It is to be noted, however, that the appended drawings illustrate onlytypical embodiments of this invention and are therefore not to beconsidered limiting of its scope, for the present invention may admit toother equally effective embodiments.

FIG. 1 is a flow chart diagram illustrating an overall clipping/cullingprocedure of a graphics processing pipeline according to one embodimentof the present invention.

FIG. 2 is a flow chart diagram illustrating clipping/culling procedurein the PA module of the graphics processing pipeline according to oneembodiment of the present invention.

FIG. 3 is a flow chart diagram illustrating clipping/culling procedurein the SE module of the graphics processing pipeline according to oneembodiment of the present invention.

DETAILED DESCRIPTION OF THE INVENTION

FIG. 1 is a flow chart diagram illustrating an overall clipping/cullingprocedure of the graphics processing pipeline according to oneembodiment of the present invention. As an example, the graphicsprocessing pipeline includes the PA module, the SE module and the RAmodule. Here, step 102 receives multiple vertices representing 3Dobjects. In some examples, the vertices may be received from a vertexshader module which computes these vertices for representing 3D objects.Step 104 converts these 3D objects from vertices to geometricprimitives, such as points, line segments (hereafter referred to aslines), triangles, or other appropriate geometric shapes. In an example,the PA module is configured in a triangle mode. In triangle mode, thevertices are converted into multiple triangles before any furtherprocessing. In another example, the PA module is configured in a linemode and converts the vertices into multiple lines before any furtherprocessing. In yet another example, the PA module is configured in pointmode and converts the vertices into multiple points before any furtherprocessing. The points may be associated with a position attribute and asize attribute that may be used in rendering steps later in the graphicsprocessing pipeline. Continuing the discussion of step 104, trianglesand lines which are completely outside the view frustum are removed,which is known as trivial rejection to those skilled in the art. If anytriangle or line is partially inside the view frustum and partiallyoutside the view frustum, only near plane clipping, or near Z clipping,will be applied to the triangle or line.

In an example, step 104 may be implemented as the following algorithmwhere (Xc, Yc, Zc) is the coordinate of a vertex in the view frustum,which is bounded by six planes defined as (a) +X plane: Xc=Wc, (b) −Xplane: Xc=−Wc, (c) +Y plane: Yc=Wc, (d) −Y plane: Yc=−Wc, (e) near Zplane: Zc=0, and (f) far Z plane: Zc=Wc. Here, the +X, −X, +Y and −Yplanes form a X, Y clipping rectangle of the view frustum. The algorithmincludes:

-   (1) Perform clipping for the triangle and line mode, don't perform    clipping for the point mode.-   (2) Check +X and −X planes, if all the vertices of triangle or line    are Xc<−Wc or Xc>Wc, the triangle or line is culled.-   (3) Check +Y and −Y planes, if all the vertices of triangle or line    are Yc<−Wc or Yc>Wc, the triangle or line is culled.-   (4) Check near Z and far Z planes, if all the vertices of triangle    or line are Zc<0 or Zc>Wc, the triangle or line is culled.-   (5) Check near Z again, if some vertices' Zc<0 and some Zc>=0,    perform near Z clipping.

In the above exemplar algorithm, the near Z clipping may be performed byvarious methods known to one skilled in the art of 3D computer graphics.What is an important aspect of the present invention is that not allsteps of view frustum clipping/culling are performed in one singlelocation in the graphics processing pipeline.

After clipping in the view frustum, the coordinates of primitives may betransformed to screen space in step 106, and sent to the SE module andthe RA module to perform the rest of the clipping.

Continuing the discussion of FIG. 1 to step 108, the SE moduledetermines the initial point of rasterization which must be inside theclipping window. Additional clipping/culling may be performed duringthis determination process. Here the clipping window resides in thescreen space. In one example, the SE module starts with the vertices ofa triangle or a line inside the clipping window as the initial point ofrasterization. If none of the vertices are inside the clipping window,it computes the initial point of rasterization as a point which is bothinside clipping window and inside the triangle or part of the line. Asan example, if the vertices of a line are outside the clipping window,the SE module may compute the intersection of the line and the clippingwindow as the initial point of rasterization. If no such intersectioncan be found, the line is culled. In another example, where the PAmodule is configured in point mode, each point as a geometric primitivemay be converted to a polygon with appropriate size according to theassociated size attribute in the SE module. The polygon may be furtherconverted as one or more triangles. In step 110, the SE moduleimplements the trivial rejection for the points after the polygonconversion. In an example, points are trivially rejected inside the PAmodule and the SE only culls if the entire primitive is outside theclipping window or beyond the far Z plane. In another example, the SEmodule performs trivial rejection (culling) if it cannot find anyintersection with the clipping window or the primitive is beyond the farZ plane. In other examples, SE module may perform the trivial rejectionto all geometric primitives including the triangles and lines for easeof implementation without having to differentiate between the modes inwhich the PA module is configured or to differentiate between geometricprimitives. In one example, the trivial rejection is performed by way ofcomputing the initial point of rasterization inside the clipping window.One skilled in the art will appreciate that the invention may bepractice with SE module performing the trivial rejection eitherincluding or excluding the other geometric primitives.

In step 112 of FIG. 1, the RA module performs per-tile, per-subtile,per-quad, and per-pixel clipping. Rasterization in the RA module may beimplemented in various manners known to one skilled in the art of 3Dcomputer graphics. In an example, the rasterization may be implementedin a hierarchical approach, such described in U.S. patent applicationSer. No. 11/592,799 (Docket No. GIQUILA-P001), filed on Nov. 3, 2006,entitled “HIERARCHICAL TILE-BASED RASTERIZATION ALGORITHM” which isincorporated herein by reference. In this exemplary rasterizationmethod, the per-tile, per-subtile, per-quad, and per-pixel clipping areperformed at the same time as the per-tile, per-subtile, per-quad, andper-pixel rendering steps of the rasterization method.

FIGS. 2 is a flow chart diagram illustrating clipping/culling procedurein the PA module of the graphics processing pipeline according to oneembodiment of the present invention. Here, a primitive such as a point,a line, or a triangle is assembled from vertices by the PA module instep 201. A decision is made in step 202 as to if X, Y, or Z of allvertices of the primitive lie outside the view frustum. If the decisionis yes, the primitive is culled in step 203. If the decision is no, thenanother decision is made in step 204 as to if the nearest Z of anyvertex is outside the view frustum. If the decision is yes, then near Zclipping is performed. In an example, for a line, the intersection withthe view frustum may be computed and sent to the setup (SE) module; fora triangle, the intersection vertices are computed and one or more newtriangles are built based on these vertices and sent to SE module. Ifthe decision of step 204 is no, then the primitive is sent to the SEmodule without further processing.

FIG. 3 is a flow chart diagram illustrating clipping/culling procedurein the SE module of the graphics processing pipeline according to oneembodiment of the present invention. In some examples, SE modulecomputes initial points of rasterization to be used by the RA module forrendering the primitives in the rasterization process. In an example, avertex inside the clipping window may be chosen as the initial point ofrasterization. If all vertices are outside the clipping window, SEmodule performs necessary clipping and compute another initial point ofrasterization. Here in step 301, a near-Z clipped primitive, which isnot trivially rejected in the PA module, is input to the SE module. Insome examples, only the X and Y coordinates are transformed into screenspace, while the per pixel Z values are stored in a Z-buffer. Then adecision is made in step 302 as to if any vertices of the primitive isoutside the far Z plane of the view frustum. If the decision is yes,then the entire primitive is culled in the far Z clipping/culling (step309). If the decision of step 302 if no, then another decision is madein step 303 as to if the primitive is a line. For the case that the PAmodule is configured in the line mode and the primitive is a line, themethod proceeds to step 304 where the decision is made as to if thestarting vertex is outside the clipping window. If the decision is no,the line is sent to the RA module (step 310). If the decision is yes,then the intersection of the line with the clipping window is computedin step 305 and a decision is made as to if the intersection is stilloutside the clipping window. For example, since the line istwo-dimensional, only one coordinate is clipped. For example, if a lineis x-major, the clipping is done by computing the y value at the nearestx clipping boundary (left or right border). The computed y-coordinatestill needs to be verified if it is outside the clipping window. If thedecision is yes, then the line is culled (step 309). If the decision isno, then the line is sent to the RA module with the computedintersections (step 310). Continuing to the decision made in step 303,for the case that the primitive is not a line, another decision is madein step 306 as to if any vertex of the primitive is inside the clippingrectangle. If no vertex is found inside the clipping window, the methodproceeds to step 308 and intersections of each edge of the primitivewith the clipping window are computed. If no intersection can be foundthat lies inside the clipping window, the entire primitive is culled(step 309). If any intersection exists, the primitive is sent to RAmodule with the first computed intersection as the initial point ofrasterization (step 310). Continuing to the decision made in step 306,for the case that any vertex of the primitive is inside the clippingwindow, the vertex of the primitive that lies within the clipping windowwill be chosen to be the initial point of rasterization and theprimitive is sent to RA module with the found vertex (step 307).

Foregoing described embodiments of the invention are provided asillustrations and descriptions. They are not intended to limit theinvention to precise form described. In particular, it is contemplatedthat functional implementation of invention described herein may beimplemented equivalently in hardware, software, firmware, and/or otheravailable functional components or building blocks, and that networksmay be wired, wireless, or a combination of wired and wireless. Othervariations and embodiments are possible in light of above teachings, andit is thus intended that the scope of invention not be limited by thisDetailed Description, but rather by Claims following.

1. A method for clipping in a 3D computer graphics processing pipeline,the 3D computer graphics processing pipeline comprises a view frustum, aclipping window, a primitive assembly (PA) module, a set up (SE) module,and a rasterization (RA) module, the method comprising: obtaining aprimitive using the PA module; performing a first clipping of theprimitive using the PA module; determining an initial point ofrasterization for the primitive using the SE module; performing a secondclipping of the primitive using the SE module; rendering the primitiveusing the RA module; and performing a third clipping of the primitiveusing the RA module.
 2. The method of claim 1, wherein the primitivecomprises one or more vertex, and wherein the first clipping removes theprimitive if the primitive has no vertex inside the view frustum.
 3. Themethod of claim 1, wherein the primitive comprises one or more vertices,and wherein the first clipping comprises a near Z clipping.
 4. Themethod of claim 1, wherein the primitive comprises one or more vertices,and wherein the second clipping comprises removing the primitive if theinitial point of rasterization for the primitive can not be determinedinside the clipping window.
 5. The method of claim 1, wherein the thirdclipping comprises: (a) inputting the initial point of rasterization forthe primitive; (b) determining if the primitive is a line or a triangle;and (c) if the primitive is a triangle, rasterizing the triangle in ahierarchical manner, comprising: (c1) walking a plurality of tiles ofpixels and determining if each tile is valid; (c2) breaking each validtile into a plurality of subtiles and determining if each subtile isvalid; (c3) breaking each valid subtile into a plurality of quads anddetermining if each quad is valid; and (c4) rendering pixels for eachvalid quad, wherein steps (c1) through (c4) are performed in parallel.6. The method of claim 5, wherein the breaking step (c2) comprises:(c2i) breaking each valid tile into the plurality of subtiles; (c2ii)walking the plurality of subtiles; and (c2iii) determining if eachsubtile is valid.
 7. The method of claim 6, wherein the walking of theplurality of subtiles is performed in a same manner as the walking ofthe plurality of tiles.
 8. The method of claim 5, wherein the breakingstep (c3) comprises: (c3i) breaking each valid subtile into theplurality of quads; (c3ii) walking the plurality of quads; and (c3iii)determining if each quad is valid.
 9. The method of claim 8, wherein thewalking of the plurality of quads is performed in a same manner as thewalking of the plurality of tiles and a walking of the plurality ofsubtiles.
 10. The method of claim 5, wherein validation of a block,wherein the block comprises a tile, a subtile, or a quad, comprises:checking if a pixel in the block sits on the left, right, or exactly ona line of a triangle using edge equations; checking four corners of theblock against three edges of the triangle and returning a combinedresult; determining if the block contains any pixels inside thetriangle, based on the combined result; and determining that the blockis valid, if the block contains at least one valid pixel inside thetriangle.
 11. The method of claim 10, further comprising: abandoning theblock, if the block does not contain at least one valid pixel inside thetriangle.
 12. The method of claim 5, further comprising: (d) if theprimitive is a line, computing pixels for each quad of pixels for theline; and (e) rendering pixels for each valid quad.
 13. The method ofclaim 1, wherein the primitive has a position and a size, and whereinthe first clipping removes the primitive if the position is outside ofthe view frustum.
 14. The method of claim 13, wherein the primitive isconverted into a polygon according to the size, wherein the polygon isconverted into a plurality of triangles in the SE module, and whereinthe second clipping removes a triangle if the triangle has no vertexinside the clipping window.
 15. The method of claim 14, wherein thethird clipping comprises: (a) inputting the initial point ofrasterization for the triangle; and (b) rasterizing the triangle in ahierarchical manner, comprising: (b1) walking a plurality of tiles ofpixels and determining if each tile is valid; (b2) breaking each validtile into a plurality of subtiles and determining if each subtile isvalid; (b3) breaking each valid subtile into a plurality of quads anddetermining if each quad is valid; and (b4) rendering pixels for eachvalid quad, wherein steps (b1) through (b4) are performed in parallel.16. The method of claim 15, wherein the breaking step (b2) comprises:(b2i) breaking each valid tile into the plurality of subtiles; (b2ii)walking the plurality of subtiles; and (b2iii) determining if eachsubtile is valid.
 17. The method of claim 16, wherein the walking of theplurality of subtiles is performed in a same manner as the walking ofthe plurality of tiles.
 18. The method of claim 15, wherein the breakingstep (b3) comprises: (b3i) breaking each valid subtile into theplurality of quads; (b3ii) walking the plurality of quads; and (b3iii)determining if each quad is valid.
 19. The method of claim 18, whereinthe walking of the plurality of quads is performed in a same manner asthe walking of the plurality of tiles and a walking of the plurality ofsubtiles.
 20. The method of claim 15, wherein validation of a block,wherein the block comprises a tile, a subtile, or a quad, comprises:checking if a pixel in the block sits on the left, right, or exactly ona line of a triangle using edge equations; checking four corners of theblock against three edges of the triangle and returning a combinedresult; determining if the block contains any pixels inside thetriangle, based on the combined result; and determining that the blockis valid, if the block contains at least one valid pixel inside thetriangle.
 21. The method of claim 20, further comprising: abandoning theblock, if the block does not contain at least one valid pixel inside thetriangle.